home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GNUGEM27 / VDIGDP.C < prev    next >
C/C++ Source or Header  |  1993-03-24  |  5KB  |  245 lines

  1. /*
  2.  *    Vdi drawing primitives library interface
  3.  *
  4.  *        v_bar        bar
  5.  *        v_arc        arc
  6.  *        v_pieslice    pie
  7.  *        v_circle    circle
  8.  *        v_ellarc    elliptical arc
  9.  *        v_ellpie    elliptical pie
  10.  *        v_ellipse    ellipse
  11.  *        v_rbox        rounded rect
  12.  *        v_rfbox     rounded filled rect
  13.  *        v_justified justified text
  14.  *
  15.  *            ++jrb    bammi@cadence.com
  16.  *            modified: mj -- ntomczak@vm.ucs.ualberta.ca
  17.  */
  18. #include <stddef.h>
  19. #include "common.h"
  20.  
  21. #ifdef __DEF_ALL__
  22.  
  23. #define L_v_bar
  24. #define L_v_arc
  25. #define L_v_piesli
  26. #define L_v_circle
  27. #define L_v_ellarc
  28. #define L_v_ellpie
  29. #define L_v_ellips
  30. #define L_v_rbox
  31. #define L_v_rfbox
  32. #define L_v_justif
  33.  
  34. #endif /* __DEF_ALL__ */
  35.  
  36.  
  37. #ifdef L_v_bar
  38.  
  39. /* v_bar    bar
  40.  * returns void
  41.  */
  42. void v_bar(int handle, int pxyarray[])
  43. {
  44. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  45.     _vdiparams[2] = (void *) &pxyarray[0];
  46. #else                    /* 32 bit ints - let's copy */
  47.     register int i;
  48.  
  49.     for(i = 0; i < 4; i++)
  50.     _ptsin[i] = pxyarray[i];
  51. #endif
  52.  
  53.     __vdi__(VDI_CONTRL_ENCODE(11, 2, 0, 1), handle);
  54.  
  55. #ifdef __MSHORT__
  56.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  57. #endif
  58. }
  59. #endif /* L_v_bar */
  60.  
  61. #ifdef L_v_arc
  62.  
  63. /* v_arc    arc
  64.  * returns void
  65.  */
  66. void v_arc(int handle, int x, int y, int radius, int begang, int endang)
  67. {
  68.     extern void bzero(void *, size_t);
  69.  
  70.     bzero(_ptsin, 8 * sizeof(short));
  71.     _ptsin[0] = x;
  72.     _ptsin[1] = y;
  73.     _ptsin[6] = radius;
  74.     _intin[0] = begang;
  75.     _intin[1] = endang;
  76.  
  77.     __vdi__(VDI_CONTRL_ENCODE(11, 4, 2, 2), handle);
  78. }
  79. #endif /* L_v_arc */
  80.  
  81. #ifdef L_v_piesli
  82.  
  83. /* v_pieslice    pie
  84.  * returns void
  85.  */
  86. void v_pieslice(int handle, int x, int y, int radius, int begang, int endang)
  87. {
  88.     extern void bzero(void *, size_t);
  89.  
  90.     bzero(_ptsin, 8 * sizeof(short));
  91.     _ptsin[0] = x;
  92.     _ptsin[1] = y;
  93.     _ptsin[6] = radius;
  94.     _intin[0] = begang;
  95.     _intin[1] = endang;
  96.  
  97.     __vdi__(VDI_CONTRL_ENCODE(11, 4, 2, 3), handle);
  98. }
  99. #endif /* L_v_piesli */
  100.  
  101. #ifdef L_v_circle
  102.  
  103. /* v_circle circle
  104.  * returns void
  105.  */
  106. void v_circle(int handle, int x, int y, int radius)
  107. {
  108.     extern void bzero(void *, size_t);
  109.  
  110.     bzero(_ptsin, 6 * sizeof(short));
  111.     _ptsin[0] = x;
  112.     _ptsin[1] = y;
  113.     _ptsin[4] = radius;
  114.  
  115.     __vdi__(VDI_CONTRL_ENCODE(11, 3, 0, 4), handle);
  116. }
  117. #endif /* L_v_circle */
  118.  
  119. #ifdef L_v_ellarc
  120.  
  121. /* v_ellarc elliptical arc
  122.  * return void
  123.  */
  124. void v_ellarc(int handle, int x, int y, int xrad, int yrad,
  125.           int begang, int endang)
  126. {
  127.     _ptsin[0] = x;
  128.     _ptsin[1] = y;
  129.     _ptsin[2] = xrad;
  130.     _ptsin[3] = yrad;
  131.     _intin[0] = begang;
  132.     _intin[1] = endang;
  133.  
  134.     __vdi__(VDI_CONTRL_ENCODE(11, 2, 2, 6), handle);
  135. }
  136. #endif /* L_v_ellarc */
  137.  
  138. #ifdef L_v_ellpie
  139.  
  140. /* v_ellpie elliptical pie
  141.  * return void
  142.  */
  143. void v_ellpie(int handle, int x, int y, int xrad, int yrad,
  144.           int begang, int endang)
  145. {
  146.     _ptsin[0] = x;
  147.     _ptsin[1] = y;
  148.     _ptsin[2] = xrad;
  149.     _ptsin[3] = yrad;
  150.     _intin[0] = begang;
  151.     _intin[1] = endang;
  152.  
  153.     __vdi__(VDI_CONTRL_ENCODE(11, 2, 2, 7), handle);
  154. }
  155. #endif /* L_v_ellpie */
  156.  
  157. #ifdef L_v_ellips
  158.  
  159. /* v_ellipse    ellipse
  160.  * returns void
  161.  */
  162. void v_ellipse(int handle, int x, int y, int xrad, int yrad)
  163. {
  164.     _ptsin[0] = x;
  165.     _ptsin[1] = y;
  166.     _ptsin[2] = xrad;
  167.     _ptsin[3] = yrad;
  168.  
  169.     __vdi__(VDI_CONTRL_ENCODE(11, 2, 0, 5), handle);
  170. }
  171. #endif /* L_v_ellips */
  172.  
  173. #ifdef L_v_rbox
  174.  
  175. /* v_rbox    rounded rect
  176.  * returns void
  177.  */
  178. void v_rbox(int handle, int pxyarray[])
  179. {
  180. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  181.     _vdiparams[2] = (void *) &pxyarray[0];
  182. #else                    /* 32 bit ints - let's copy */
  183.     register int i;
  184.  
  185.     for(i = 0; i < 4; i++)
  186.     _ptsin[i] = pxyarray[i];
  187. #endif
  188.  
  189.     __vdi__(VDI_CONTRL_ENCODE(11, 2, 0, 8), handle);
  190.  
  191. #ifdef __MSHORT__
  192.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  193. #endif
  194. }
  195. #endif /* L_v_rbox */
  196.  
  197. #ifdef L_v_rfbox
  198.  
  199. /* v_rfbox    rounded filled rect
  200.  * returns void
  201.  */
  202. void v_rfbox(int handle, int pxyarray[])
  203. {
  204. #ifdef __MSHORT__        /* we have 16 bit ints, just change vdi params */
  205.     _vdiparams[2] = (void *) &pxyarray[0];
  206. #else                    /* 32 bit ints - let's copy */
  207.     register int i;
  208.  
  209.     for(i = 0; i < 4; i++)
  210.     _ptsin[i] = pxyarray[i];
  211. #endif
  212.  
  213.     __vdi__(VDI_CONTRL_ENCODE(11, 2, 0, 9), handle);
  214.  
  215. #ifdef __MSHORT__
  216.     _vdiparams[2] = (void *)&_ptsin[0]; /* restore vdi parameters */
  217. #endif
  218. }
  219. #endif /* L_v_rfbox */
  220.  
  221. #ifdef L_v_justif
  222.  
  223. /* v_justified    justified text
  224.  * returns void
  225.  */
  226. void v_justified(int handle, int x, int y, char *str, int len,
  227.          int word_space, int char_space)
  228. {
  229.     register short *wptr = _intin;
  230.  
  231.     _ptsin[0] = x;
  232.     _ptsin[1] = y;
  233.     _ptsin[2] = len;
  234.     _ptsin[3] = 0;
  235.     *wptr++ = word_space;
  236.     *wptr++ = char_space;
  237.     while (0 != (*wptr = (unsigned char) *str++))
  238.     wptr += 1;
  239.  
  240.     __vdi__(VDI_CONTRL_ENCODE(11, 2, (int)(wptr - _intin), 10), handle);
  241. }
  242. #endif /* L_v_justif */
  243.  
  244. /* -eof- */
  245.